class Simulator::SystemsController < ApplicationController
	#active_scaffold
	layout 'simulator/simulator'
	def index
		@systems = search(params[:search], params[:page], params[:sort])
	end
	
	def show
		@system = System.find(params[:id])
	end

	def start_simulation
		SimulationRun.new(params[:simulation_id])
		redirect_to :action => :show, :id => params[:id]
	end

	def search(search, page, sort)
		sort = case sort
					 when "name" then "name"
					 when "name_reverse" then "name DESC"
					 when "hd_number" then "hd_number"
					 when "hd_number_reverse" then "hd_number DESC"
					 when "hip_number" then "hip_number"
					 when "hip_numer_reverse" then "hip_number DESC"
					 end
					 
  	System.paginate :per_page => 10, :page => page,
  					 				:conditions => ['name like ?', "%#{search}%"],
  					 				:order => sort
  end
  
end
